{% extends "main/base.html" %}
{% load i18n %}
{% block title %}{% trans '设备组装详情' %}{% endblock %}
{% block content %}
<div class="row">
    <aside class="profile-nav col-lg-3 alt green-border">
        <section class="panel">
            <div class="user-heading alt green-bg">
                <h1>{{ object.assembly_name }}</h1>
                {% if perms.main.view_equipment_basic_price %}<p>{% trans '部件成本' %}: {{ object.total_value }}</p>{% endif %}
            </div>
            <ul class="nav nav-pills nav-stacked">
                <li class="active"><a href=""><i class="fa fa-gear"></i> {% trans '组装详情' %} </a></li>
                {% if perms.main.change_equipmentassembly %}{% if object %}<li><a href="{% url 'main:equipment_als_update' object.pk %}?next={{ request.path }}"> <i class="fa fa-edit"></i> {% trans '编辑资料' %}  </a></li>{% endif %}{% endif %}
                {% if perms.main.add_assemblyitem %}{% if object %}<li><a href="{% url 'main:assembly_item_create' %}?a={{ object.pk }}&next={{ request.path }}"> <i class="fa fa-plus"></i> {% trans '添加部件' %}  </a></li>{% endif %}{% endif %}
                {% if request.user.is_staff or perms.main.view_all_orders %}<li><a href="{% url 'main:ea_export' object.pk %}"><i class="fa fa-share"></i> {% trans '导出文件' %} </a></li>{% endif %}
            </ul>
        </section>
    </aside>
    <aside class="profile-info col-lg-9">
        <section class="panel">
            <div class="panel-heading">
                <h4 class="heading">{% trans '主设备名称' %}: <a href="{% url 'main:equipment_detail' object.equipment.pk %}">{{ object.equipment.equipment_cn|default_if_none:'N/A' }}/{{ object.equipment.equipment_en|default_if_none:'' }}</a></h4>
            </div>
            <div class="panel-body bio-graph-info">
                <div class="row">
                    <div class="bio-row">
                        <p><span>{% trans '备注' %}: </span>{{ object.notes }}</p>
                    </div>
                </div>
            </div>
        </section>
        <section class="panel">
            <header class="panel-heading">
                {% trans "部件列表" %}
            </header>
            {% get_current_language as LANGUAGE_CODE %}
            <div class="table-responsive panel-body">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>{% trans '排序参数' %}</th>
                            <th>ID</th>
                            <th>{% trans '设备中文名' %}/{% trans '设备英文名' %}</th>
                            <th>{% trans '设备类型' %}</th>
                            <th>{% trans '数量' %}</th>
                            <th>{% trans '库存' %}</th>{% if perms.main.view_equipment_basic_price %}
                            <th>{% trans '单价' %}/{% trans '小计' %}</th>{% endif %}
                            <th>{% trans '备注' %}</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>{% for d in object.assembly_list %}
                        <tr>
                            <td>{{ d.order_index }}</td>
                            <td>{{ d.equipment.pk }}</td>
                            <td><a href="{% url 'main:equipment_detail' d.equipment.id %}">{{ d.equipment.equipment_code }}</a><br>
                                {{ d.equipment.equipment_cn }}<br>
                                {{ d.equipment.equipment_en }}
                            </td>
                            <td>{{ d.equipment.equipment_type }}</td>
                            <td><label class="btn btn-success">{{ d.amount }}</label></td>
                            <td>
                                <label data-original-title="{% trans '库存信息' %}" data-content="{% for k, v in d.equipment.amount_left.items %}{% if not forloop.first %}{{ k }}: {{ v }}; {% endif %}{% endfor %}" data-placement="bottom" data-trigger="hover" class="btn btn-info popovers">{{ d.equipment.amount_left.total }}</label>
                            </td>{% if perms.main.view_equipment_basic_price %}
                            <td>{{ d.equipment.basic_price|default_if_none:'' }}<br>
                                {{ d.total_value|default_if_none:'' }}
                            </td>{% endif %}
                            <td>{{ d.notes }}</td>
                            <td>{% if perms.main.change_equipmentassembly %}
                                <a href="{% url 'main:assembly_item_update' d.pk %}?next={% url 'main:equipment_assembly_detail' object.pk %}"><button class="btn btn-success btn-xs"><i class="fa fa-pencil"></i></button></a>
                                {% endif %}
                            </td>
                        </tr>{% endfor %}
                    </tbody>
                </table>
            </div>
        </section>
    </aside>
</div>
{% endblock %}